import json
import time

from flask import Flask, Response, request

app = Flask(__name__)

@app.route('/stream', methods=['GET'])
def stream_data():
    def generate_data():
        for i in range(10):  # 模拟生成流式数据
            yield json.dumps({'value': i}) + '\n'
            time.sleep(1)  # 间隔 1 秒发送一次数据
    return Response(generate_data(), mimetype='application/json')

if __name__ == '__main__':
    app.run(host='192.168.3.122', port=5000, debug=True)